package com.baomidou.ant.controller;

import com.baomidou.ant.common.Result;
import com.baomidou.ant.service.ICheckInfoService;
import com.baomidou.ant.vo.request.RequestCheckPassVo;
import com.baomidou.ant.vo.request.RequestDtoVo;
import com.baomidou.ant.vo.request.RequestListCheckInfoVo;
import com.baomidou.ant.vo.response.ResponseCheckInfoVo;
import com.baomidou.ant.vo.response.ResponseListCheckInfoVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2022-03-18
 */
@RestController
@RequestMapping("/check-info")
public class CheckInfoController {
    @Autowired
    private ICheckInfoService checkInfoService;

    //审核通过
    @PostMapping("/checkPass")
    public Result checkPass(@RequestBody RequestCheckPassVo vo){
       if(checkInfoService.checkPass(vo)){
           return Result.getSuccess().setMsg("审核完毕");
       }else
           return Result.getFailure().setMsg("审核失败");
    }

    //分页查询
    @PostMapping("/listCheckInfo")
    public Result listCheckInfo(@RequestBody RequestListCheckInfoVo requestListCheckInfoVo){
        IPage<ResponseListCheckInfoVo> page=checkInfoService.listCheck(requestListCheckInfoVo);
        return Result.getSuccess().setData(page);
    }

    //页数总数
    @PostMapping("/getTotal")
    public Result getTotal(@RequestBody RequestDtoVo requestDtoVo){
        return null;
    }

    //详情接口
    @GetMapping("/checkInfo/{orderNum}")
    public Result checkInfo(@PathVariable String orderNum){
        ResponseCheckInfoVo vo=checkInfoService.getCheckInfo(orderNum);
        return Result.getSuccess().setData(vo);
    }

}
